package com.slf.common.controller;

import com.slf.common.util.Result;
import com.slf.common.util.ResultCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author slf
 * @date 2021/7/4
 */
@RestController
public class BaseController {
    protected Logger log = LoggerFactory.getLogger(this.getClass());


    /**
     * 请求成功
     *
     * @param data 数据内容
     * @param <T>  对象泛型
     * @return ignore
     */
    protected <T> Result<T> success(T data) {
        return Result.success(data);
    }

    /**
     * 请求失败
     *
     * @param msg 提示内容
     * @return ignore
     */
    protected <T> Result<T> failed(String msg) {
        return Result.failed(msg);
    }

    /**
     * 请求失败
     *
     * @param resultCode 请求错误码
     * @return ignore
     */
    protected <T> Result<T> failed(ResultCode resultCode) {
        return Result.failed(resultCode);
    }
}
